﻿@using TBM.Models
@{
	User Info = (User)ViewBag.UserInfo;
	string LargePic = TBM.Core.Config.DefaultPic;
	string SmallPic = LargePic;

	if(!String.IsNullOrEmpty(Info.PicUrl)){
		LargePic = Info.PicUrl + "large.png?" + DateTime.Now.Ticks;
		SmallPic = Info.PicUrl + "small.png?" + DateTime.Now.Ticks;
	}
}
<div class="row">
  <div class="col-md-12">
    <!-- BEGIN PORTLET -->
    <div class="portlet light">
      <div class="portlet-title tabbable-line">
        <div class="caption caption-md">
          <i class="icon-globe theme-font hide"></i>
          <span class="caption-subject font-blue-madison bold uppercase">个人信息设置</span>
        </div>
        <ul class="nav nav-tabs">
          <li class="active">
            <a href="#tab_info" data-toggle="tab">个人信息 </a>
          </li>
          <li>
            <a href="#tab_avatar" data-toggle="tab">更改头像 </a>
          </li>
          <li>
            <a href="#tab_password" data-toggle="tab">修改密码 </a>
          </li>
          <li>
            <a href="#tab_permission" data-toggle="tab">权限信息 </a>
          </li>
        </ul>
      </div>
      <div class="portlet-body">
        <!--BEGIN TABS-->
        <div class="tab-content">
          <!--个人信息-->
          <div class="tab-pane active" id="tab_info">
            <form id="updateForm" role="form" action="~/User/UpdateProfileInfo">
              <div class="form-body">
                <div class="form-group">
                  <label class="control-label">* 姓氏</label>
                  <span></span>
                  <input name="firstname" type="text" placeholder="姓氏" class="form-control" value="@Info.FirstName" />
                </div>
                <div class="form-group">
                  <label class="control-label">* 名字</label>
                  <span></span>
                  <input name="lastname" type="text" placeholder="名字" class="form-control" value="@Info.LastName" />
                </div>
                <div class="form-group">
                  <label class="control-label">中文名？</label>
                  <div class="checkbox-list">
                    <label class="checkbox-inline">
                      <input type="radio" name="cnname" value="true" @(Info.CNName ? "checked=\"checked\"" : "")/> 是
                    </label>
                    <label class="checkbox-inline">
                      <input type="radio" name="cnname" value="false" @(!Info.CNName ? "checked=\"checked\"" : "")/> 否
                    </label>
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label">所属分组</label>
                  @Info.Groups
                </div>
                <div class="form-group">
                  <label class="control-label">* Email</label>
                  <span></span>
                  <input name="email" type="text" placeholder="Email" class="form-control" value="@Info.Email" />
                </div>
                <div class="form-group">
                  <label class="control-label">通讯电话</label>
                  <span></span>
                  <input name="phone" type="text" placeholder="通讯电话" class="form-control" value="@Info.Phone" />
                </div>
                <div class="form-group">
                  <label class="control-label">QQ</label>
                  <span></span>
                  <input name="qq" type="text" placeholder="QQ" class="form-control" value="@Info.QQ" />
                </div>
                <div class="form-group">
                  <label class="control-label">备注信息</label>
                  <span></span>
                  <textarea name="memo" class="form-control" rows="3" placeholder="关于TA的备注">@Info.Memo</textarea>
                </div>
                <div class="margiv-top-10">
                  <button id="btnUpdateUser" type="button" class="btn green-haze">更新</button>
                  <button id="btnUpdateUserCancel" type="button" class="btn default">取消</button>
                </div>
              </div>
            </form>
          </div>
          <!--/End 个人信息-->
          <!--更改头像-->
          <div class="tab-pane" id="tab_avatar">
            <div class="alert alert-warning">
              更新头像后，原始头像将被删除
            </div>
            <form id="avatarForm" action="~/User/UpdateProfileAvatar" role="form">
              <div class="form-group clearfix">
                <div id="avatarLargePreview" class="large-preview pull-left">
                  <img src="@LargePic" height="125" />
                </div>
                <div  id="avatarSmallPreview" class="small-preview pull-left ml-20">
                  <img src="@SmallPic" height="30" />
                </div>
                <span class="btn btn-primary fileinput-button pull-left ml-20">
                  <i class="fa fa-photo"></i>
                  <span>选择头像</span>
                  <input id="fileAvatar" type="file" name="avatar" />
                </span>
              </div>
              <div class="margin-top-10">
                <button id="btnUpload" type="button" class="btn green-haze">更新头像</button>
                <button id="btnCancelUpload" type="button" class="btn default">取消</button>
              </div>
            </form>
          </div>
          <!--/End 更改头像-->
          <!--修改密码-->
          <div class="tab-pane" id="tab_password">
            <form id="updatePasswordForm" action="~/User/UpdateProfilePWD">
              <div class="hide">
                <!--用来修正webkit浏览器自动补全密码问题-->
                <input name="no" type="password" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label">当前密码</label>
                <span></span>
                <input name="currpassword" type="password" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label">新的密码</label>
                <span></span>
                <input id="newpassword" name="newpassword" type="password" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label">确认密码</label>
                <span></span>
                <input name="confirmpassword" type="password" class="form-control" />
              </div>
              <div class="margin-top-10">
                <button id="btnUpdatePWD" type="button" class="btn green-haze">更新密码</button>
                <button id="btnCancelUpdatePWD" type="button" class="btn default">取消</button>
              </div>
            </form>
          </div>
          <!--/End 修改密码-->
          <!--权限信息-->
          <div class="tab-pane" id="tab_permission">
            <table class="table table-light">
              <tbody>
                @foreach(var Parent in ViewBag.ModuleList){
                <tr>
                  <td>
                    <div class="checkbox-list mb-10">
                      <label class="checkbox-inline align-left @(Parent.Key.IsChecked ? "text-success" : "")">
                        @if(Parent.Key.IsChecked){
                        <i class="fa fa-check"></i>
                        }
                        <b> @("[" + Parent.Key.ControllerDescr + "] " + Parent.Key.ActionDescr) </b>
                      </label>
                    </div>
                    <div class="checkbox-list pl-50">
                      @foreach(TBM.Models.Module item in Parent.Value){
                      <label class="checkbox-inline align-left @(item.IsChecked ? "text-success" : "")">
                        @if(item.IsChecked){
                        <i class="fa fa-check"></i>
                        }
                        @item.ActionDescr
                      </label>
                      }
                    </div>
                  </td>
                </tr>
                }
              </tbody>
            </table>
          </div>
          <!--/End 权限信息-->
        </div>
        <!--END TABS-->
      </div>
    </div>
    <!-- END PORTLET -->
  </div>
</div>
<script type="text/javascript">
  jQuery(document).ready(function () {
    ProfileSetting.init();
  });
</script>